/**
 * 
 */
package niuke;

import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 黑白卡片 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		String string=scanner.nextLine();
		
		int startWithBDistance=0;
		int startWithWDistance=0;
		char shouldChar='B';
		for (int i = 0; i < string.length(); i++) {
			if(shouldChar!=string.charAt(i)){
				startWithBDistance++;
			}
			shouldChar=(shouldChar=='W'?'B':'W');
		}
		shouldChar='W';
		for (int i = 0; i < string.length(); i++) {
			if(shouldChar!=string.charAt(i)){
				startWithWDistance++;
			}
			shouldChar=(shouldChar=='W'?'B':'W');
		}
		System.out.println(Math.min(startWithBDistance, startWithWDistance));
	}

}
